﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebForm
{
    public partial class CallBackCode : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string s = "if (event.which || event.keyCode) { " +
                     "if ((event.which == 13) || (event.keyCode == 13)) { " +
                    "document.getElementById('" + btnOther.ClientID + "').click();  return false;}} else {return true;}";
                
            
            
            TextBox1.Attributes.Add("onkeydown", s);
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            this.Title = "ttttttttttttttttt";
        }

        protected void Button1_Click1(object sender, EventArgs e)
        {
            txtBox.Text = "第2个按钮";
        }

       

        protected void btnOther_Click(object sender, EventArgs e)
        {
            btnOther.Text = "新的测试";
        } 
        protected void Button2_Click(object sender, EventArgs e)
        {
            //注意：如果调用前台的js函数时，一定要将js函数放在html的head中或用其它办法保证要调用的方法已注册
            ClientScript.RegisterStartupScript(this.GetType(), "SayHello", "<script>test();</script>");//调用前台的JS函数;
            ClientScript.RegisterStartupScript(this.GetType(), "SayHello1", "test();", true);
          
        }
    }
}